Skip to content

feat(zipapp): support EXTRACT_ROOT env var for __main__.py invocations#3682

Merged
rickeylev merged 4 commits intobazel-contrib:mainfrom
rickeylev:zipapp.main.extract.root
Apr 5, 2026
Merged

feat(zipapp): support EXTRACT_ROOT env var for __main__.py invocations#3682
rickeylev merged 4 commits intobazel-contrib:mainfrom
rickeylev:zipapp.main.extract.root

Conversation

@rickeylev
Copy link
Copy Markdown
Collaborator

@rickeylev rickeylev commented Apr 5, 2026

This makes zipapps that are invoked using the __main__.py entry point
(i.e. python foo.zip) respect the RULES_PYTHON_EXTRACT_ROOT env var, which
allows some control over where they extract themselves.

@rickeylev rickeylev requested a review from aignas as a code owner April 5, 2026 00:27
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the ability to specify a custom extraction root for Python zipapps via the RULES_PYTHON_EXTRACT_ROOT environment variable, allowing for persistent extraction locations instead of temporary directories. Feedback was provided regarding potential race conditions and file corruption when multiple instances extract to the same fixed location simultaneously. Additionally, there is an inconsistency in the use of os.path.join versus a direct join import, and a concern that the new -XRULES_PYTHON_ZIP_DIR flag is not passed consistently when a custom extraction root is used.

@rickeylev rickeylev changed the title feat(zipapp): support RULES_PYTHON_EXTRACT_ROOT env var feat(zipapp): support EXTRACT_ROOT env var for __main__.py invocations Apr 5, 2026
@rickeylev rickeylev enabled auto-merge April 5, 2026 00:50
@rickeylev rickeylev added this pull request to the merge queue Apr 5, 2026
Merged via the queue into bazel-contrib:main with commit 6d38770 Apr 5, 2026
4 checks passed
@rickeylev rickeylev deleted the zipapp.main.extract.root branch April 5, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants